/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedBeans;

import controladores.ConsultarReservaCont;
import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import modelos.pojos.Reserva;
import org.apache.log4j.Logger;

/**
 *
 * @author ricardo
 */
@ManagedBean
@ViewScoped
public class Factura implements Serializable {

    private modelos.pojos.Reserva reserva;
    protected Logger log = Logger.getLogger(Factura.class);
    
    /** Creates a new instance of Factura */
    public Factura() {
        reserva = new Reserva();
    }

    public Reserva getReserva() {
        return reserva;
    }

    public void setReserva(Reserva reserva) {
        this.reserva = reserva;
    }
    
    public void consultarReserva() {
        Reserva reservaAFacturar = ConsultarReservaCont.consultarReserva(reserva.getCodigoReserva());
        if(reservaAFacturar!=null){
            reserva = reservaAFacturar;
            String codigoReserva = reservaAFacturar.getCodigoReserva();
            log.info(codigoReserva.substring(2, codigoReserva.length()));
        } else {
            FacesContext context = FacesContext.getCurrentInstance();
            context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,"No existe reserva con el código especificado",""));
        }
    }    
}
